package com.hmdp.mapper;

import com.hmdp.entity.Blog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
public interface BlogMapper extends BaseMapper<Blog> {

    @Select(value = "select * from tb_blog where id  = #{id}")
    public Blog queryById(Long id);

    @Update("update tb_blog set liked = liked + #{number} where id = #{id} ")
    boolean updateLiked(@Param("number") Integer number, @Param("id") Long id);

    @Select("select * from tb_blog where user_id = #{id}")
    List<Blog> queryAllByUserId(Long id);

    boolean insertRecord(@Param("blog") Blog blog);

    List<Blog> queryByIds(@Param("blogIds") List<Long> blogIds);
}
